#ifndef DRAWING_HPP
#define DRAWING_HPP
#include <stdint.h>
#include <stdbool.h>
#include "lcd.hpp"
#include "image.hpp"

using namespace device;

namespace ui
{	
	class drawing
	{
		public:
			typedef struct
			{
				uint16_t usAscWidth;
				uint16_t usAscHeight;
				uint16_t usAscLength;
				uint16_t usGb2312Width;
				uint16_t usGb2312Height;
				uint16_t usGb2312Length;
				const uint8_t *ucAscDatabaseAddr;
				const uint16_t *usGb2312MapAddr;
				const uint8_t *ucGb2312DatabaseAddr;
			}FontModuleTPDF;
            int font_swprintf(wchar_t[],const char*,...);///<Only ASCII allowed!!!!!!
            short font_wcslen(const wchar_t*);
		private:
			lcd *mLcd;
			FontModuleTPDF* mFontModule;  ///> 字体信息
			int16_t dEncoderFind(uint16_t usEncoder); ///编码
		public:
			typedef enum
			{
				TEXT_ALIGN_LEFT = 0,
				TEXT_ALIGN_CENTER,
				TEXT_ALIGN_RIGHT,
			}TextAlignTPDF;
		
			typedef enum
			{
				PAINT_STYLE_STROKE = 0,			///<绘制边框
				PAINT_STYLE_FILL,						///<绘制实心
			}PaintStyleTPDF;							///<绘制类型
			
			typedef enum
			{
				DASH_STYLE_SOLID = 0,				///<实线
				DASH_STYLE_DOT,							///<点
				DASH_STYLE_DASHDOT,					///<点划线
			}DashStyleTPDF;								///<线类型
			
			typedef struct
			{
				PaintStyleTPDF PaintStyle;	///<绘制类型
				DashStyleTPDF DashStyle;		///<线类型
				bool Invert;								///<颜色取反
				uint32_t Width;							///<线宽
				lcd::RGBTPDF Color;					///<颜色
			}Paint;												///<绘图

			drawing(lcd *tLcd);
			void InitFontModule(uint32_t uiAddr); ///> 初始化字体
			void Clear(void);
			void DrawLine(Paint *tPaint, uint32_t uiStartX, uint32_t uiStartY, uint32_t uiEndX, uint32_t uiEndY);
			void DrawRectangle(Paint *tPaint, uint32_t uiStartX, uint32_t uiStartY, uint32_t uiEndX, uint32_t uiEndY);
			void DrawString(Paint *tPaint, const wchar_t *String, uint32_t uiX, uint32_t uiY);
			void DrawString(Paint *tPaint, const wchar_t *String, uint32_t uiSatrtX, uint32_t uiEndX, uint32_t uiY, TextAlignTPDF tTextAlign);
			void DrawImage(image *tImg, uint32_t uiStartX, uint32_t uiStartY);
			const lcd::ResolutionTPDF* GetResolution(void);
			uint16_t MeasureString(const wchar_t *String);
	};
}

#endif
